#include <queue>
#include <mutex>
#include <condition_variable>
#include"MysqlConn.h"
using namespace std;
class ConnectionPool
{
public:
    static ConnectionPool* getConnetPool();
    ConnectionPool(const ConnectionPool& obj) = delete;//禁用拷贝构造函数
    ConnectionPool& operator=(const ConnectionPool& obj) = delete;//禁用拷贝赋值运算符
    shared_ptr<MysqlConn> getConnetion();
    ~ConnectionPool();
private:
    ConnectionPool();//构造函数设置为私有
    bool parseJsonFile();
    void produceConnection();
    void recycleConnection();
    void addConnection();
    string m_ip;
    string m_user;
    string m_passwd;
    string m_dbName;
    unsigned short m_port;
    int m_minSize;
    int m_maxSize;
    int m_timeout;
    int m_maxIdleTime;
    queue<MysqlConn*> m_connectionQ;
    mutex m_mutexQ;
    condition_variable m_cond;
};//单例模式